#include <normalEntry.h>

namespace lgb_gtk
{

  NormalEntry::NormalEntry()
  {
    x = 0;
    y = 0;
    width = 200;
    height = 30;
    hasCoverChar = false;
    coverChar = ' ';
  }

  NormalEntry::~NormalEntry()
  {

  }

  int NormalEntry::Init()
  {
    if(hasInit)
      return 1;

    entry = gtk_entry_new();
    gtk_entry_set_text((GtkEntry*)entry , text.c_str());
    if(' ' == coverChar){
      gtk_entry_set_visibility((GtkEntry *)entry, TRUE);
    }else{
      gtk_entry_set_visibility((GtkEntry *)entry, FALSE);
      gtk_entry_set_invisible_char((GtkEntry *)entry, coverChar);
    }
    goo_canvas_widget_new(canvas , entry , x , y , width , height , NULL);

    hasInit = true;
    return 0;
  }

  string NormalEntry::GetText()
  {
    if(hasInit)
      text = gtk_entry_get_text((GtkEntry*)entry);
    return text;
  }
  using namespace std;

  int NormalEntry::SetText(string newText)
  {
    text = newText;
    if(hasInit)
      gtk_entry_set_text((GtkEntry*)entry , text.c_str());
    return 0;
  }

  int NormalEntry::SetCoverChar(char newChar)
  {
    coverChar = newChar;
    return 0;
  }

  bool NormalEntry::HasCoverChar()
  {
    return hasCoverChar;
  }
  

}
